package org.dei.perla.rockfall.gui.queryforge;

import javax.swing.BoxLayout;
import javax.swing.JPanel;

import org.dei.perla.rockfall.gui.queryforge.panels.RunningStatus1Panel;
import org.dei.perla.rockfall.gui.queryforge.panels.RunningStatus2Panel;
import org.dei.perla.rockfall.gui.queryforge.panels.RunningStatus3Panel;
import org.dei.perla.rockfall.gui.queryforge.panels.RunningStatus4Panel;
import org.dei.perla.rockfall.gui.queryforge.panels.RunningStatus5Panel;
import org.dei.perla.rockfall.gui.queryforge.panels.RunningStatus6Panel;

public class RunningStatusPanel extends JPanel implements ParameterConfigurationManipulator{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private DSPicParameters dspicParameters;
	private RunningStatus1Panel rs1Panel;
	private RunningStatus2Panel rs2Panel;
	private RunningStatus3Panel rs3Panel;
	private RunningStatus4Panel rs4Panel;
	private RunningStatus5Panel rs5Panel;
	private RunningStatus6Panel rs6Panel;
	
	private JPanel commandPanel;
	
	public RunningStatusPanel(DSPicParameters param) {
		super();
		BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
		this.setLayout(boxLayout);
		this.dspicParameters = param;
		this.rs1Panel = new RunningStatus1Panel("RS1");
		this.rs2Panel = new RunningStatus2Panel("RS2");
		this.rs3Panel = new RunningStatus3Panel("RS3");
		this.rs4Panel = new RunningStatus4Panel("RS4");
		this.rs5Panel = new RunningStatus5Panel("RS5");
		this.rs6Panel = new RunningStatus6Panel("RS6");
			
		this.add(this.rs1Panel);
		this.add(this.rs2Panel);
		this.add(this.rs3Panel);
		this.add(this.rs4Panel);
		this.add(this.rs5Panel);
		this.add(this.rs6Panel);
	}

	public void updateConfiguration() {
		this.rs1Panel.setStatus(this.dspicParameters.getRs1());
		this.rs2Panel.setStatus(this.dspicParameters.getRs2());
		this.rs3Panel.setStatus(this.dspicParameters.getRs3());
		this.rs4Panel.setStatus(this.dspicParameters.getRs4());
		this.rs5Panel.setStatus(this.dspicParameters.getRs5());
		this.rs6Panel.setStatus(this.dspicParameters.getRs6());
	}

	@Override
	public void readConfiguration() {
		if(this.dspicParameters != null){
			this.dspicParameters.setRs1(rs1Panel.getStatus());
			this.dspicParameters.setRs2(rs2Panel.getStatus());
			this.dspicParameters.setRs3(rs3Panel.getStatus());
			this.dspicParameters.setRs4(rs4Panel.getStatus());
			this.dspicParameters.setRs5(rs5Panel.getStatus());
			this.dspicParameters.setRs6(rs6Panel.getStatus());	
		}
	}
}
